package com.example.shiro.service.impl;

import com.example.shiro.entity.SysUserEntity;
import com.example.shiro.service.SessionService;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description :
 * @Author : Bruce Lee
 * @CreateTime : 2024/5/30
 */

@Service
public class SessionServiceImpl implements SessionService {

    @Autowired
    private SessionDAO sessionDAO;


    @Override
    public Integer getSessionCount() {
        return sessionDAO.getActiveSessions().size();
    }

    @Override
    public List<SysUserEntity> list() {
        return null;
    }

    @Override
    public boolean forceLogout(String sessionId) {
        Session session = sessionDAO.readSession(sessionId);
        session.setTimeout(0);
        return true;
    }
}
